namespace CoreManager.Elasticsearch.Models;

/// <summary>
/// Elasticsearch配置选项
/// </summary>
public class ElasticsearchOptions
{
    public const string SectionName = "Elasticsearch";
    
    /// <summary>
    /// ES服务器地址
    /// </summary>
    public string Uri { get; set; } = "http://localhost:9200";
    
    /// <summary>
    /// 用户名
    /// </summary>
    public string? Username { get; set; }
    
    /// <summary>
    /// 密码
    /// </summary>
    public string? Password { get; set; }
    
    /// <summary>
    /// 默认索引前缀
    /// </summary>
    public string IndexPrefix { get; set; } = "coremanager";
    
    /// <summary>
    /// 连接超时时间（秒）
    /// </summary>
    public int TimeoutSeconds { get; set; } = 30;
    
    /// <summary>
    /// 是否启用调试模式
    /// </summary>
    public bool EnableDebugMode { get; set; } = false;
    
    /// <summary>
    /// 最大重试次数
    /// </summary>
    public int MaxRetries { get; set; } = 3;
    
    /// <summary>
    /// 索引配置
    /// </summary>
    public IndexOptions Indexes { get; set; } = new();
}

/// <summary>
/// 索引配置选项
/// </summary>
public class IndexOptions
{
    /// <summary>
    /// 日志索引
    /// </summary>
    public string Logs { get; set; } = "logs";
    
    /// <summary>
    /// 用户行为索引
    /// </summary>
    public string UserActivities { get; set; } = "user-activities";
    
    /// <summary>
    /// 系统事件索引
    /// </summary>
    public string SystemEvents { get; set; } = "system-events";
    
    /// <summary>
    /// 审计日志索引
    /// </summary>
    public string AuditLogs { get; set; } = "audit-logs";
    
    /// <summary>
    /// 获取完整索引名称
    /// </summary>
    public string GetFullIndexName(string indexName, string prefix)
    {
        return $"{prefix}-{indexName}";
    }
}

